<?php
/**
 * @author 段志岩
 * @date 2008.9.3
 * @summary 取得各论坛的前几个帖子
 */

class SubForumPostView extends View{
	private $number;
	private $order;
	
	public function __construct()
	{
		parent::__construct();

		$this->sql = "SELECT u.truename, post.*
			FROM (
				SELECT * FROM posts a WHERE
			( SELECT count(1) FROM posts WHERE forum_id = a.forum_id AND `time` > a.time) <=";
		$this->order = " ) as post, users as u  WHERE post.author_id = u.uid  ORDER BY forum_id ASC";
	}
	public function setNumber($number)
	{
		$this->number = (int)($number -1);
	}
	public function toSql()
	{
		return $this->sql . $this->number .  $this->order;
	}
};
?>
